package no.rmz.chez.game.reporters;

import no.rmz.chez.game.reporters.GameReporter;
import no.rmz.chez.chess.board.ChessBoard;
import no.rmz.chez.chess.board.Color;
import no.rmz.chez.chess.pieces.ChessPiece;
import no.rmz.chez.game.Move;
import no.rmz.chez.misc.Timer;

/**
 * Report the progress of a game by printing stuff to
 * standard output. Implements a singelton pattern for instance
 * access.
 *
 */
public  class StdoutGameReporter implements GameReporter {
    
    

    /**
     * Set my timer.
     */
    @Override
    public void setMyTimer(Timer t) {
        // TODO Auto-generated method stub
    }
    
    /**
     * Implementing the singelton pattern.
     *
     */
    public  StdoutGameReporter() {
    }

    /**
     * The only instance of this kind of GameReporter.
     */
    private static final StdoutGameReporter INSTANCE
        = new StdoutGameReporter();

    /**
     * Getting to the singelton instance of GameReporter.
     * @return the singelton instance.
     */
    public static  StdoutGameReporter getInstance() {
        return INSTANCE;
    }
    
    /* (non-Javadoc)
     * @see no.rmz.chez.game.GameReporter#logMove(no.rmz.chez.chess.ChessPiece, no.rmz.chez.game.Move, no.rmz.chez.chess.ChessBoard)
     */
    @Override
    public final void logMove(
            final int moveNo,
            final ChessPiece piece,
            final Move  m,
            final ChessBoard b) {
        System.out.println("\n" + moveNo + "->" + m.getACNRepresentation());
        System.out.println(b);
    }

    /* (non-Javadoc)
     * @see no.rmz.chez.game.GameReporter#reportResult()
     */
    @Override
    public final void reportResult() {
    
    }

    /* (non-Javadoc)
     * @see no.rmz.chez.game.GameReporter#reportDeadlock()
     */
    @Override
    public final void reportDeadlock() {
        System.out.println("No more moves detected, exiting");
    }

    /* (non-Javadoc)
     * @see no.rmz.chez.game.GameReporter#reportTie()
     */
    @Override
    public void reportTie() {
    
    }

    /* (non-Javadoc)
     * @see no.rmz.chez.game.GameReporter#handleNormalTermination(no.rmz.chez.chess.Color)
     */
    @Override
    public final void handleNormalTermination(final Color winner) {
        System.out.println("Game over, winner is " + winner);
    }
}
